SHELL=/usr/bin/env bash

all: build-deps build

unexport GOFLAGS

.PHONY: all build

TARGET=./miners-monitor

build: clean
	go build -o $(TARGET)

build-deps: clean-deps
	git submodule update --init --recursive
	make -C ./extern/lotus deps

.PHONY: clean clean-lotus switch-interop switch-master
clean:
	-rm -f ${TARGET}

clean-deps:
	-make -C ./extern/lotus clean

switch-master:
	git submodule set-branch --branch master extern/lotus

switch-interop:
	git submodule set-branch --branch interopnet extern/lotus

watch:
	-pkill -9 fishcmd
	-pkill -9 miners-monitor
	-pkill -9 main
	nohup fishcmd run miners-monitor --watch &
	tail -f nohup.out
release:
	go run models/tool/startPrepare/startPrepare.go
	go generate
	go build
	sudo supervisorctl restart miners-monitor
	sudo tail -f ../data/log/access.log
gen:
	go generate
test:
	go generate
	go test ./models/...
stop:
	sudo supervisorctl stop miners-monitor
	-pkill -9 bee
	-pkill -9 goldenstatue
docker-build:
	sudo docker build -t miners-monitor .
docker-run:
	# sudo docker run --network host -d -p 9000:9000 -p 27017:27017 -p 1234:1234 miners-monitor
	sudo docker run -d --name miners-monitor --network liangmingyao_default -p 9000:9000 miners-monitor
docker-mongo:
	# sudo docker run -d --network host --name mongodb  -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin666 -v /opt/gukesoft/middleware/mongo/db:/data/db -v /etc/localtime:/etc/localtime mongo:4.4
	sudo docker run -d --network liangmingyao_default -p 27017:27017 --name mongodb  -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin666 -v /opt/gukesoft/middleware/mongo/db:/data/db -v /etc/localtime:/etc/localtime mongo:4.4

